package com.gxa.modules.deviceManager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Query;
import com.gxa.modules.deviceManager.entity.MaintenanceRecord;
import com.gxa.modules.deviceManager.mapper.MaintenanceRecordMapper;
import com.gxa.modules.deviceManager.service.MaintenanceRecordService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class MaintenanceRecordServiceImpl extends ServiceImpl<MaintenanceRecordMapper, MaintenanceRecord> implements MaintenanceRecordService {

    @Override
    public PageUtils queryByPage(Map<String, Object> params) {
        String equipmentName = (String)params.get("equipmentName");
        String equipmentNumber = (String)params.get("equipmentNumber");
        String communityId = (String)params.get("communityId");

        IPage<MaintenanceRecord> page = this.page(new Query<MaintenanceRecord>().getPage(params),
                new QueryWrapper<MaintenanceRecord>().like(StringUtils.isNotEmpty(equipmentName),"equipment_name",equipmentName).eq(StringUtils.isNotEmpty(equipmentNumber),"equipment_number",equipmentNumber)
                        .eq(StringUtils.isNotEmpty(communityId),"community_id",communityId)
        );
        return new PageUtils(page);
    }



}
